package lament.tryRetrofit;

import java.io.IOException;

import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;
import xyz.lament.ApiClient;
import xyz.lament.api.GreetingApi;
import xyz.lament.model.Greeting;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
    	ApiClient apiClient = new ApiClient();
    	Retrofit.Builder builder = new Retrofit.Builder()
        	.baseUrl("http://localhost:8080/")
        	.addConverterFactory(JacksonConverterFactory.create());
    	apiClient.setAdapterBuilder(builder);    	

    	GreetingApi service = apiClient.createService(GreetingApi.class);
    	
    	Call<Greeting> userCall = service.greeting("jimi");
    	try {
    		Response<Greeting> resultResponse = userCall.execute();
    		System.out.println("Hello World!:");
    		System.out.println(resultResponse.body().toString());
		} catch (IOException e) {
			e.printStackTrace();
		}
    }
}
